﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient.

namespace 陈明
{
    class Program
    {
        static void Main(string[] args)
        {
            string connectionString = "server =.;database =ad;uid=sa;pwd=123456";

            SqlConnection sqlConnection = new SqlConnection(connectionString);

            sqlConnection.Open();

            var sqlCommandString = "select *from UserName";
            sqlCommand sqlCommand = new sqlCommand(sqlCommandString, sqlConnection);

            var sdr = sqlCommand.ExecuteReader();

            Console.WriteLine("{0}\t{1}\t{2}", "名字","年龄", "性别");

            while (sdr.Read())
            {
                Console.WriteLine("{0}\t{1}\t{2}",sdr["Name"],sdr["Age"],sdr["Sex"]);
            }

            sqlConnection.Close();
                
        }
    }
}
